package sapling.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2017/6/2.
 */
@Entity
@Getter
@Setter
public class Tree {
    public static final int TYPE_TREE_AWAIT_SELL=0;//待售
    public static final int TYPE_TREE_OUT=1;//出库
    public static final int TYPE_TREE_AWAIT_OUT=2;//待出库
    public static final int TYPE_TREE_SIGN=3;//号苗
    public static final int TYPE_TREE_DIE=4;//死苗
    public static final int TYPE_TREE_AWAIT_DIE=5;//待死苗

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long tree_id;
    private String username;//入库人
    private String sename;
    private String serialNumber;//编号
    private String imgurl;//树貌
    private String treeSpecies;//树种
    private double height=0;//高度
    private double heightmax;//高度
    private double chestBreadth=0;//胸径/地径
    private double chestBreadthmax;//胸径/地径
    private double crownWidth;//冠幅
    private double crownWidthmax;//冠幅
    private Boolean clump;//是否丛生
    private Boolean payment;//是否付款
    private Boolean gather;//是否收款
    private int salenumber=0;//枝条数
    private int salenumbermax;//枝条数
    private int healthstate=0;//(0健康 1.坏树)
    @Temporal(TemporalType.TIMESTAMP)
    private Date putNurseryTime;//入圃时间
    @Temporal(TemporalType.TIMESTAMP)
    private Date outWarehouseTime;//出库时间
    @ManyToOne
    @JoinColumn(name = "batch_id", referencedColumnName = "id")
    @JsonIgnore
    private Batch batch;//所属批次
    private String location;//产地
    private int salesState;//苗木流转状态（0、待售；1、出库；2待出库;3号苗;4.死苗;5.待死苗）
    private int responseState;//入库状态(0.待审核 1.已经生成批次)
    private String remark;//备注
    private double price=0.0;//单价
    private double totalprice;//总价
    private int number=1;//数量
    private int welltype=0;//树坑类型(0.#字 1.井字)
    private String sales;//树苗
    private long tree_well_id;//树坑id
    private long landmassid;//对应地id
    private String place;//位置
    private String direction;//售出去向
    private double cost;//当前成本
    @OneToMany(mappedBy = "tree", cascade = {CascadeType.ALL})
    @JsonIgnore
    private List<GrowthRecord> growthRecords = new ArrayList<>();//一个棵树的所有成长记录

    @ManyToOne
    @JoinColumn(name = "outboundOrder_id", referencedColumnName = "id")
    @JsonIgnore
    private OutboundOrder outboundOrder;//所属订单

    @ManyToOne
    @JoinColumn(name = "mark_id", referencedColumnName = "id")
    @JsonIgnore
    private Markorder markorder;//号苗订单

    @ManyToOne
    @JoinColumn(name = "update_id", referencedColumnName = "id")
    @JsonIgnore
    private Updateorder updateorder;//更新订单

    @Temporal(TemporalType.TIMESTAMP)
    @CreationTimestamp
    private Date createtime;

    @Temporal(TemporalType.TIMESTAMP)
    @UpdateTimestamp
    @JsonIgnore
    private Date updateTime;

}
